package org.example.controller;


import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.exception.model.ResponseResult;
import org.example.vo.ScanVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author yangzhenyu
 * */
@Validated
@RestController
@Slf4j
@RequestMapping(value="api/test")
public class TestController {



    @Operation(
            summary = "测试接口",
            description = "通过微服务调触发此测试接口",
            requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
                    description = "调用测试接口的对象",
                    required = true,
                    content = @Content(
                            mediaType = "application/json",
                            schema = @Schema(implementation = ScanVo.class)
                    )
            ),
            responses = {
                    @ApiResponse(responseCode = "201", description = "测试成功"),
                    @ApiResponse(responseCode = "400", description = "请求错误")
            }
    )
    @CrossOrigin(origins = "*")  //处理跨域请求的注解
    @RequestMapping(value = "/scan", method = RequestMethod.POST)
    public String scan(@Validated @RequestBody ScanVo scanVo) {
        String format = String.format("路径 %s!", scanVo.getPath());
        log.info(format);
        return format;
    }




}
